import Vue from "vue";
import VueRouter from "vue-router";
import store from "../store";
import Home from "../views/Home.vue";
import login from "../views/login.vue";
import business from "../views/Business.vue";
import perfectOne from "../components/perfectInformation/perfectOne.vue";
import perfectTwo from "../components/perfectInformation/perfectTwo.vue";
import setPasswor from "../components/perfectInformation/setPasswor.vue";
let originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};

Vue.use(VueRouter);
const routes = [
   
    {
        path: "/",
        name: "Home",
        component: Home,
    },
    {
        path: "/login",
        name: "login",
        component: login,
        children: [{
                path: "/login",
                component: () =>
                    import ("@/components/login/login.vue"),
            },
            {
                path: "register",
                component: () =>
                    import ("@/components/login/register.vue"),
            },
            {
                path: "modify",
                component: () =>
                    import ("@/components/modify/modify.vue"),
                children: [{
                        path: "/",
                        name: "password",
                        component: () =>
                            import ("@/components/modify/password.vue"),
                    },
                    {
                        path: "edit",
                        component: () =>
                            import ("@/components/modify/edit.vue"),
                        beforeEnter: (to, from, next) => {
                            if (from.path == "/login/modify") {
                                next();
                            } else {
                                next("/login");
                            }
                        },
                    },
                ],
            },
        ],
    },
    {
        path: "/business",
        name: "business",
        component: business,
        redirect: "/business/allBusiness",
        children: [{
                path: "allBusiness",
                component: () =>
                    import ("@/components/BaseComponents/AsiderBusiness.vue"),
                redirect: "/business/allBusiness/register",
                children: [{
                        path: "register",
                        component: () =>
                            import ("@/components/component/BashStep.vue"),
                    },
                    {
                        path: "businessclou",
                        name: "businessclou",
                        component: () =>
                            import ("@/components/BusinessCenter/businessclou.vue"),
                    },
                    {
                        path: "perfectOne",
                        component: perfectOne,
                        beforeEnter: (to, from, next) => {
                            store.state.finishStatus == 0 ?
                                next() :
                                next("/business/allBusiness/information");
                        },
                    },
                    {
                        path: "perfectTwo",
                        component: perfectTwo,
                    },
                    {
                        path: "setPassword",
                        name: "setPasswor",
                        component: setPasswor,
                        beforeEnter: (to, from, next) => {
                            store.state.flat == 0 ?
                                next() :
                                next("/business/allBusiness/changePassword");
                        },
                    },
                    {
                        path: "BashStep",
                        component: () =>
                            import ("@/components/component/BashStep.vue"),
                    },
                    {
                        path: "changePassword",
                        name: "changePassword",
                        component: () =>
                            import ("@/components/perfectInformation/changePassword.vue"),
                    },
                    {
                        path: "information",
                        component: () =>
                            import ("@/components/perfectInformation/information.vue"),
                    },
                ],
            },
            {
                path: "myBusiness",
                component: () =>
                    import ("@/components/BaseComponents/AsiderAudit.vue"),
                children: [{
                        path: "/",
                        component: () =>
                            import ("@/components/subscribe/auditing.vue"),
                    },
                    {
                        path: "auditing",
                        component: () =>
                            import ("@/components/subscribe/auditing.vue"),
                    },
                    {
                        path: "auditlose",
                        component: () =>
                            import ("@/components/subscribe/auditlose.vue"),
                    },
                    {
                        path: "auditwin",
                        component: () =>
                            import ("@/components/subscribe/auditwin.vue"),
                    },
                    {
                        path: "subscribewin",
                        component: () =>
                            import ("@/components/subscribe/subscribewin.vue"),
                    },
                    {
                        path: "subscribeClassify",
                        component: () =>
                            import ("@/components/subscribe/subscribeClassify.vue"),
                    },
                    {
                        path: "perfectOne",
                        component: perfectOne,
                        beforeEnter: (to, from, next) => {
                            store.state.finishStatus == 0 ?
                                next() :
                                next("/business/myBusiness/information");
                        },
                    },

                    {
                        path: "information",
                        component: () =>
                            import ("@/components/perfectInformation/information.vue"),
                    },
                    {
                        path: "mybussinessForm1",
                        component: () =>
                            import ("@/components/detailPage/businessForm1.vue"),
                    },
                    {
                        path: "mybussinessForm2",
                        component: () =>
                            import ("@/components/detailPage/businessForm2.vue"),
                    },
                    {
                        path: "mybussinessForm3",
                        component: () =>
                            import ("@/components/detailPage/businessForm3.vue"),
                    },
                    {
                        path: "mybussinessForm4",
                        component: () =>
                            import ("@/components/detailPage/businessForm4.vue"),
                    },
                    {
                        path: "mybussinessForm5",
                        component: () =>
                            import ("@/components/detailPage/businessForm5.vue"),
                    },
                    {
                        path: "mybussinessForm6",
                        component: () =>
                            import ("@/components/detailPage/businessForm6.vue"),
                    },
                    {
                        path: "mybussinessForm7",
                        component: () =>
                            import ("@/components/detailPage/businessForm7.vue"),
                    },
                    {
                        path: "mybussinessForm8",
                        component: () =>
                            import ("@/components/detailPage/businessForm8.vue"),
                    },
                    {
                        path: "mybussinessForm9",
                        component: () =>
                            import ("@/components/detailPage/businessForm9.vue"),
                    },
                    {
                        path: "mybussinessForm10",
                        component: () =>
                            import ("@/components/detailPage/businessForm10.vue"),
                    },
                    {
                        path: "mybussinessForm11",
                        component: () =>
                            import ("@/components/detailPage/businessForm11.vue"),
                    },
                    {
                        path: "mybussinessForm12",
                        component: () =>
                            import ("@/components/detailPage/businessForm12.vue"),
                    },
                    {
                        path: "mybussinessForm13",
                        component: () =>
                            import ("@/components/detailPage/businessForm13.vue"),
                    },
                    {
                        path: "mybussinessForm14",
                        component: () =>
                            import ("@/components/detailPage/businessForm14.vue"),
                    },
                    {
                        path: "mybussinessForm15",
                        component: () =>
                            import ("@/components/detailPage/businessForm15.vue"),
                    },
                    {
                        path: "mybussinessForm16",
                        component: () =>
                            import ("@/components/detailPage/businessForm16.vue"),
                    },
                    {
                        path: "mybussinessForm17",
                        component: () =>
                            import ("@/components/detailPage/businessForm17.vue"),
                    },
                    {
                        path: "mybussinessForm18",
                        component: () =>
                            import ("@/components/detailPage/businessForm18.vue"),
                    },
                    {
                        path: "mybussinessForm19",
                        component: () =>
                            import ("@/components/detailPage/businessForm19.vue"),
                    },
                    {
                        path: "mybussinessForm20",
                        component: () =>
                            import ("@/components/detailPage/businessForm20.vue"),
                    },
                    {
                        path: "mybussinessForm21",
                        component: () =>
                            import ("@/components/detailPage/businessForm21.vue"),
                    },
                    {
                        path: "mybussinessForm22",
                        component: () =>
                            import ("@/components/detailPage/businessForm22.vue"),
                    },
                    {
                        path: "mybussinessForm24",
                        component: () =>
                            import ("@/components/detailPage/businessForm24.vue"),
                    },
                    {
                        path: "mybussinessForm25",
                        component: () =>
                            import ("@/components/detailPage/businessForm25.vue"),
                    },
                ],
            },
        ],
    },
    {
        path: "/pre",
        component: () =>
            import ("@/components/component/pre.vue"),
    },
];

const router = new VueRouter({
    mode: "history",
    routes,
});

export default router;